package io.renren.modules.store.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.store.dao.TStoreBrandDao;
import io.renren.modules.store.entity.TStoreBrandEntity;
import io.renren.modules.store.service.TStoreBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("tStoreBrandService")
public class TStoreBrandServiceImpl extends ServiceImpl<TStoreBrandDao, TStoreBrandEntity> implements TStoreBrandService {

    @Autowired
    private TStoreBrandDao storeBrandDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TStoreBrandEntity> page = this.page(
                new Query<TStoreBrandEntity>().getPage(params),
                new QueryWrapper<TStoreBrandEntity>()
                        .eq(!params.get("sellerId").equals(""),"seller_id",params.get("sellerId"))
        );

        return new PageUtils(page);
    }

    @Override
    public Long getMaxBrand(Long seller) {
        return storeBrandDao.getMaxBrand(seller);
    }

}